package bairui.international.weixin.portal.miniapp.controller.pack.order;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lianjing.sh.spring.web.controller.base.action.Action;
import com.lianjing.sh.spring.web.controller.enhance.output.FomatOutput;

import bairui.international.model.status.State_ProductOrder;
import bairui.international.service.Service_ProductOrder;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 *
 * 列表
 *
 * @generated
 * 
 * @see STest_C_Pack_Order_Page_Get 测试
 *
 */
@Controller
public class C_Pack_Order_Page_Get
 extends SC_Pack_Order_Page_Get 
{
	@Autowired private Service_ProductOrder productOrder;
//	@Autowired private Service_ProductOrderPack service_ProductOrderPack;
	
	/**
	 * Get请求
	 */
	@Action(Get.class)
	@GetMapping(Get.RequestMappingValue)
	public @FomatOutput @ResponseBody Object get(
		ModelMap map, HttpServletRequest request,
		@RequestParam Integer startPage,
		@RequestParam String skey
	) throws Exception {
//		Page<TB_ProductOrder> page = productOrder.page(
//				it->it.user.skey.eq(skey)
//					.and(it.type.eq(Type_ProductOrder.Pack)),
//				PageRequest.of(startPage, 5),
//				it->new QSort(it.submitDate.desc(), it.createTime.desc())
//			);
//		return page.map(it->new Output(
//				it.getId(), 
//				it.getNumber(), 
//				it.getState(),
//				it.getState().getComment(),
//				it.getScore(), 
//				it.getAmount(), 
//				service_ProductOrderPack
//					.list(it2->it2.productOrder.eq(it))
//					.stream()
//					.map(it2->new ItemOutput(
//							it2.getId().toString(),
//							it2.getProductName(), 
//							it2.getProductNumber(), 
//							it2.getProductPrice(),
//							new C_Pack_Order_ShowImg_Get.Get.Operate() {
//								@Override public Object getId() {
//									return it2.getId();
//								}
//							}.getUrl()
//						))
//					.collect(Collectors.toList())
//			));
		return null;
	}
	
	@AllArgsConstructor
	public static class Output {
		@Getter private long id;
		@Getter private String number;
		@Getter private State_ProductOrder state;
		@Getter private String stateComment;
		@Getter private Double totalScore;
		@Getter private Long amount;
		@Getter private List<ItemOutput> items;
		
	}

	@AllArgsConstructor
	public static class ItemOutput {
		@Getter private String id;
		@Getter private String name;
		@Getter private String number;
		@Getter private Double price;
		@Getter private String imgUrl;
	}
	

}
